ParcelLabel API
Label Creation process
There are two processes which can be followed to generate a label, you can either:
- Poll our API
- Utilize our webhook functionality
Flow 1: Polling our API
With this process, there are three key steps you need to follow to generate a label:
- Send a label creation request to the Create Label(s) endpoint - either domestic or international. This endpoint will return back a consignment id.
- Using the consignment id retrieved from step 1, repeatedly call the "Get Status of Label(s)" endpoint until the status of the consignment is complete. The recommended polling time is once every second, you should stop polling if the consignment status isn't complete within 30 seconds OR if an error is encountered.
- Send a request to download the label(s) in the consignment.
Figure 1: The ParcelLabel V3 polling process
Flow 2: Utilizing our Webhooks
Alternatively, merchants are able to choose to receive consignment notifications via a webhook so that they do not have to continually call the "Get Status of Label(s)" endpoint. This requires merchants to build a web service which can receive and process webhooks.
If all labels of the consignment have been successfully generated, the status of the labels are sent to the URL specified in notification_endpoint field.
If any of the labels in the consignment has failed to be generated, an error message is sent to the URL specified in notification_endpoint field.
Please refer to Get Status of Label(s) to see the response message and samples.